import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.teleal.cling.controlpoint.ActionCallback;
import org.teleal.cling.model.action.ActionInvocation;
import org.teleal.cling.model.message.UpnpResponse;
import org.teleal.cling.model.meta.Service;


/**
 * Implementation of the GetSortCapabilities action.
 * 
 * @author Sam SmithReams
 *
 */
public class SortCapabilities extends ActionCallback
{
	private List<String> tagNames;
	
	public List<String> getTagNames()
	{
		return tagNames;
	}

	public SortCapabilities(Service service)
	{
		super(new ActionInvocation(service.getAction("GetSortCapabilities")));
		tagNames = new ArrayList<String>();
	}

	@Override
	public void success(ActionInvocation invocation)
	{
		String sortCaps = invocation.getOutput("SortCaps").getValue().toString();
		StringTokenizer tokenizer = new StringTokenizer(sortCaps, ",");
		while(tokenizer.hasMoreTokens())
		{
			tagNames.add(tokenizer.nextToken());
		}		
	}

	@Override
	public void failure(ActionInvocation invocation, UpnpResponse operation,
			String defaultMsg)
	{
		// Do nothing
		
	}
}
